/**
 *                            License
 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS
 * CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE").
 * THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.
 * ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR
 * COPYRIGHT LAW IS PROHIBITED.
 *
 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND
 * AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE
 * MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED
 * HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
 *
 */
package l1j.server.server.clientpackets;

import l1j.opqlo.Server.L1World.L1World;
import l1j.server.echo.ClientThread;
import l1j.server.server.model.L1Object;
import l1j.server.server.model.Instance.L1BoardInstance;

import java.util.logging.Level;
import java.util.logging.Logger;
// Referenced classes of package l1j.server.server.clientpackets:
// ClientBasePacket, C_BoardPage

/**
 * 收到由客戶端傳送公告欄回到上一頁的封包
 */
public class C_BoardBack extends ClientBasePacket {

	private static final String C_BOARD_BACK = "[C] C_BoardBack";
	private static final Logger _log = Logger.getLogger(C_BoardBack.class.getName());
	@Override
	public String getType() {
		return C_BOARD_BACK;
	}

	@Override
	public void start(final byte[] decrypt, final ClientThread client) {
		try {
			// 資料載入
			this.read(decrypt);
		final int objId = this.readD();
		final int topicNumber = this.readD();
		final L1Object obj = L1World.getInstance().findObject(objId);
		final L1BoardInstance board = (L1BoardInstance) obj;
		board.onAction(client.getActiveChar(), topicNumber);
		} catch (final Exception e) {
			_log.log(Level.SEVERE, e.getLocalizedMessage(), e);

		} finally {
			this.over();
		}
	}

}
